using GroupSix.Domain.Entity.App;
using GroupSix.Domain.common;

namespace GroupSix.Domain.Repositories;

/// <summary>
/// 角色仓库接口
/// </summary>
public interface IRoleRepository : IRepository<GsRole>
{
    /// <summary>
    /// 检查角色名称是否存在
    /// </summary>
    /// <param name="name">角色名称</param>
    /// <param name="excludeId">排除的角色ID</param>
    /// <returns>是否存在</returns>
    Task<bool> IsNameExistsAsync(string name, Guid? excludeId = null);

    /// <summary>
    /// 根据名称获取角色
    /// </summary>
    /// <param name="name">角色名称</param>
    /// <returns>角色实体</returns>
    Task<GsRole?> GetByNameAsync(string name);

    /// <summary>
    /// 分页查询角色列表
    /// </summary>
    /// <param name="request">查询请求</param>
    /// <param name="name">角色名称搜索</param>
    /// <returns>分页结果</returns>
    Task<PageResult<GsRole>> GetPagedAsync(PageRequest request, string? name = null);

    /// <summary>
    /// 获取角色及其关联的菜单
    /// </summary>
    /// <param name="id">角色ID</param>
    /// <returns>角色实体</returns>
    Task<GsRole?> GetWithMenusAsync(Guid id);

    /// <summary>
    /// 检查角色是否被用户使用
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns>是否被使用</returns>
    Task<bool> IsUsedByUsersAsync(Guid roleId);

    /// <summary>
    /// 获取角色的用户数量
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns>用户数量</returns>
    Task<int> GetUserCountAsync(Guid roleId);

    /// <summary>
    /// 批量删除角色菜单关联
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns>删除数量</returns>
    Task<int> DeleteRoleMenusAsync(Guid roleId);

    /// <summary>
    /// 批量添加角色菜单关联
    /// </summary>
    /// <param name="roleMenus">角色菜单关联列表</param>
    /// <returns>添加数量</returns>
    Task<int> AddRoleMenusAsync(IEnumerable<GsRoleMenu> roleMenus);
    
    /// <summary>
    /// 获取角色菜单关联
    /// </summary>
    /// <param name="roleIds">角色ID列表</param>
    /// <returns>角色菜单关联列表</returns>
    Task<List<GsRoleMenu>> GetRoleMenusAsync(List<Guid> roleIds);
} 